import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import {
  IsOptional,
  IsString,
  MaxLength,
  MinLength,
  IsNotEmpty,
  IsEmail,
  IsPhoneNumber,
  IsDate,
  ValidateNested
} from "class-validator";
import { GoodsAttribute } from './goods_attribute.entity';

@Entity()
export class Attribute {
  @PrimaryGeneratedColumn()
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', nullable: false, comment:"商品类型"})
  attribute_category_id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 60, nullable: false})
  name: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'tinyint', nullable: false, comment:"当添加商品时,该属性的添加类别; 0为手功输入;1为选择输入;2为多行文本输入"})
  input_type: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'text', nullable: false, comment:"即选择输入,则attr_name对应的值的取值就是该这字段值"})
  value: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'tinyint', nullable: false})
  sort_order: number;

  @OneToMany(type => GoodsAttribute, goodsAttribute => goodsAttribute.attribute)
  goodsAttribute:GoodsAttribute[]
}
